package com.utils;

import cn.hutool.dfa.SensitiveUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.dao.MgcConfigDao;
import com.entity.MgcConfig;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

/**
 * 作者：WXH
 * 时间：2025/5/1
 * 描述：冲冲冲！！！
 */
@Service
public class MgcUtils {

    @Autowired
    private MgcConfigDao mgcConfigDao;

    @PostConstruct
    private void init(){
        initSensitive();
    }

    // 初始化敏感词
    public void initSensitive(){
        List<MgcConfig> mgcConfigs = mgcConfigDao.selectList(new EntityWrapper<MgcConfig>()
                .eq("status", "开启"));
        mgcConfigs.forEach(item->{
            ArrayList<String> list = new ArrayList<>();
            list.add(item.getMgName());
            SensitiveUtil.init(list);
        });
    }
}
